package com.example.springpethospital.service;

import com.example.springpethospital.config.MinioConfig;
import io.minio.MinioClient;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class MinioClientService {

    @Resource
    private MinioConfig minioConfig;

    private MinioClient minioClient;

    public MinioClient getMinioClient() {
        if (minioClient == null) {
            minioClient = MinioClient.builder()
                .endpoint(minioConfig.getEndpoint())
                .credentials(minioConfig.getAccessSecret(), minioConfig.getAccessKey())
                .build();
        }
        return minioClient;
    }
}
